<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span>  * Constructs a new mark with default properties. Marks, with the exception of
<span class='line'>  3</span>  * the root panel, are not typically constructed directly; instead, they are
<span class='line'>  4</span>  * added to a panel or an existing mark via {@link pv.Mark#add}.
<span class='line'>  5</span>  *
<span class='line'>  6</span>  * @class Represents a data-driven graphical mark. The &lt;tt>Mark&lt;/tt> class is
<span class='line'>  7</span>  * the base class for all graphical marks in Protovis; it does not provide any
<span class='line'>  8</span>  * specific rendering functionality, but together with {@link Panel} establishes
<span class='line'>  9</span>  * the core framework.
<span class='line'> 10</span>  *
<span class='line'> 11</span>  * &lt;p>Concrete mark types include familiar visual elements such as bars, lines
<span class='line'> 12</span>  * and labels. Although a bar mark may be used to construct a bar chart, marks
<span class='line'> 13</span>  * know nothing about charts; it is only through their specification and
<span class='line'> 14</span>  * composition that charts are produced. These building blocks permit many
<span class='line'> 15</span>  * combinatorial possibilities.
<span class='line'> 16</span>  *
<span class='line'> 17</span>  * &lt;p>Marks are associated with &lt;b>data&lt;/b>: a mark is generated once per
<span class='line'> 18</span>  * associated datum, mapping the datum to visual &lt;b>properties&lt;/b> such as
<span class='line'> 19</span>  * position and color. Thus, a single mark specification represents a set of
<span class='line'> 20</span>  * visual elements that share the same data and visual encoding. The type of
<span class='line'> 21</span>  * mark defines the names of properties and their meaning. A property may be
<span class='line'> 22</span>  * static, ignoring the associated datum and returning a constant; or, it may be
<span class='line'> 23</span>  * dynamic, derived from the associated datum or index. Such dynamic encodings
<span class='line'> 24</span>  * can be specified succinctly using anonymous functions. Special properties
<span class='line'> 25</span>  * called event handlers can be registered to add interactivity.
<span class='line'> 26</span>  *
<span class='line'> 27</span>  * &lt;p>Protovis uses &lt;b>inheritance&lt;/b> to simplify the specification of related
<span class='line'> 28</span>  * marks: a new mark can be derived from an existing mark, inheriting its
<span class='line'> 29</span>  * properties. The new mark can then override properties to specify new
<span class='line'> 30</span>  * behavior, potentially in terms of the old behavior. In this way, the old mark
<span class='line'> 31</span>  * serves as the &lt;b>prototype&lt;/b> for the new mark. Most mark types share the
<span class='line'> 32</span>  * same basic properties for consistency and to facilitate inheritance.
<span class='line'> 33</span>  *
<span class='line'> 34</span>  * &lt;p>The prioritization of redundant properties is as follows:&lt;ol>
<span class='line'> 35</span>  *
<span class='line'> 36</span>  * &lt;li>If the &lt;tt>width&lt;/tt> property is not specified (i.e., null), its value
<span class='line'> 37</span>  * is the width of the parent panel, minus this mark's left and right margins;
<span class='line'> 38</span>  * the left and right margins are zero if not specified.
<span class='line'> 39</span>  *
<span class='line'> 40</span>  * &lt;li>Otherwise, if the &lt;tt>right&lt;/tt> margin is not specified, its value is
<span class='line'> 41</span>  * the width of the parent panel, minus this mark's width and left margin; the
<span class='line'> 42</span>  * left margin is zero if not specified.
<span class='line'> 43</span>  *
<span class='line'> 44</span>  * &lt;li>Otherwise, if the &lt;tt>left&lt;/tt> property is not specified, its value is
<span class='line'> 45</span>  * the width of the parent panel, minus this mark's width and the right margin.
<span class='line'> 46</span>  *
<span class='line'> 47</span>  * &lt;/ol>This prioritization is then duplicated for the &lt;tt>height&lt;/tt>,
<span class='line'> 48</span>  * &lt;tt>bottom&lt;/tt> and &lt;tt>top&lt;/tt> properties, respectively.
<span class='line'> 49</span>  *
<span class='line'> 50</span>  * &lt;p>While most properties are &lt;i>variable&lt;/i>, some mark types, such as lines
<span class='line'> 51</span>  * and areas, generate a single visual element rather than a distinct visual
<span class='line'> 52</span>  * element per datum. With these marks, some properties may be &lt;b>fixed&lt;/b>.
<span class='line'> 53</span>  * Fixed properties can vary per mark, but not &lt;i>per datum&lt;/i>! These
<span class='line'> 54</span>  * properties are evaluated solely for the first (0-index) datum, and typically
<span class='line'> 55</span>  * are specified as a constant. However, it is valid to use a function if the
<span class='line'> 56</span>  * property varies between panels or is dynamically generated.
<span class='line'> 57</span>  *
<span class='line'> 58</span>  * &lt;p>See also the &lt;a href="../../api/">Protovis guide&lt;/a>.
<span class='line'> 59</span>  */</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="NAME">pv.Mark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'> 62</span>    * TYPE 0 constant defs
<span class='line'> 63</span>    * TYPE 1 function defs
<span class='line'> 64</span>    * TYPE 2 constant properties
<span class='line'> 65</span>    * TYPE 3 function properties
<span class='line'> 66</span>    * in order of evaluation!
<span class='line'> 67</span>    */</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT">  </span><span class="NAME">this.$properties</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT">  </span><span class="NAME">this.$handlers</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 71</span> 
<span class='line'> 72</span> </span><span class="COMM">/** @private Records which properties are defined on this mark type. */</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="NAME">pv.Mark.prototype.properties</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 74</span> 
<span class='line'> 75</span> </span><span class="COMM">/** @private Records the cast function for each property. */</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="NAME">pv.Mark.cast</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 77</span> 
<span class='line'> 78</span> </span><span class="COMM">/**
<span class='line'> 79</span>  * @private Defines and registers a property method for the property with the
<span class='line'> 80</span>  * given name.  This method should be called on a mark class prototype to define
<span class='line'> 81</span>  * each exposed property. (Note this refers to the JavaScript
<span class='line'> 82</span>  * &lt;tt>prototype&lt;/tt>, not the Protovis mark prototype, which is the {@link
<span class='line'> 83</span>  * #proto} field.)
<span class='line'> 84</span>  *
<span class='line'> 85</span>  * &lt;p>The created property method supports several modes of invocation: &lt;ol>
<span class='line'> 86</span>  *
<span class='line'> 87</span>  * &lt;li>If invoked with a &lt;tt>Function&lt;/tt> argument, this function is evaluated
<span class='line'> 88</span>  * for each associated datum. The return value of the function is used as the
<span class='line'> 89</span>  * computed property value. The context of the function (&lt;tt>this&lt;/tt>) is this
<span class='line'> 90</span>  * mark. The arguments to the function are the associated data of this mark and
<span class='line'> 91</span>  * any enclosing panels. For example, a linear encoding of numerical data to
<span class='line'> 92</span>  * height is specified as
<span class='line'> 93</span>  *
<span class='line'> 94</span>  * &lt;pre>m.height(function(d) d * 100);&lt;/pre>
<span class='line'> 95</span>  *
<span class='line'> 96</span>  * The expression &lt;tt>d * 100&lt;/tt> will be evaluated for the height property of
<span class='line'> 97</span>  * each mark instance. The return value of the property method (e.g.,
<span class='line'> 98</span>  * &lt;tt>m.height&lt;/tt>) is this mark (&lt;tt>m&lt;/tt>)).&lt;p>
<span class='line'> 99</span>  *
<span class='line'>100</span>  * &lt;li>If invoked with a non-function argument, the property is treated as a
<span class='line'>101</span>  * constant. The return value of the property method (e.g., &lt;tt>m.height&lt;/tt>)
<span class='line'>102</span>  * is this mark.&lt;p>
<span class='line'>103</span>  *
<span class='line'>104</span>  * &lt;li>If invoked with no arguments, the computed property value for the current
<span class='line'>105</span>  * mark instance in the scene graph is returned. This facilitates &lt;i>property
<span class='line'>106</span>  * chaining&lt;/i>, where one mark's properties are defined in terms of another's.
<span class='line'>107</span>  * For example, to offset a mark's location from its prototype, you might say
<span class='line'>108</span>  *
<span class='line'>109</span>  * &lt;pre>m.top(function() this.proto.top() + 10);&lt;/pre>
<span class='line'>110</span>  *
<span class='line'>111</span>  * Note that the index of the mark being evaluated (in the above example,
<span class='line'>112</span>  * &lt;tt>this.proto&lt;/tt>) is inherited from the &lt;tt>Mark&lt;/tt> class and set by
<span class='line'>113</span>  * this mark. So, if the fifth element's top property is being evaluated, the
<span class='line'>114</span>  * fifth instance of &lt;tt>this.proto&lt;/tt> will similarly be queried for the value
<span class='line'>115</span>  * of its top property. If the mark being evaluated has a different number of
<span class='line'>116</span>  * instances, or its data is unrelated, the behavior of this method is
<span class='line'>117</span>  * undefined. In these cases it may be better to index the &lt;tt>scene&lt;/tt>
<span class='line'>118</span>  * explicitly to specify the exact instance.
<span class='line'>119</span>  *
<span class='line'>120</span>  * &lt;/ol>&lt;p>Property names should follow standard JavaScript method naming
<span class='line'>121</span>  * conventions, using lowerCamel-style capitalization.
<span class='line'>122</span>  *
<span class='line'>123</span>  * &lt;p>In addition to creating the property method, every property is registered
<span class='line'>124</span>  * in the {@link #properties} map on the &lt;tt>prototype&lt;/tt>. Although this is an
<span class='line'>125</span>  * instance field, it is considered immutable and shared by all instances of a
<span class='line'>126</span>  * given mark type. The &lt;tt>properties&lt;/tt> map can be queried to see if a mark
<span class='line'>127</span>  * type defines a particular property, such as width or height.
<span class='line'>128</span>  *
<span class='line'>129</span>  * @param {string} name the property name.
<span class='line'>130</span>  * @param {function} [cast] the cast function for this property.
<span class='line'>131</span>  */</span><span class="WHIT">
<span class='line'>132</span> </span><span class="NAME">pv.Mark.prototype.property</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">cast</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.hasOwnProperty</span><span class="PUNC">(</span><span class="STRN">"properties"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT">    </span><span class="NAME">this.properties</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.extend</span><span class="PUNC">(</span><span class="NAME">this.properties</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">  </span><span class="NAME">this.properties</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>137</span> 
<span class='line'>138</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>139</span>    * Define the setter-getter globally, since the default behavior should be the
<span class='line'>140</span>    * same for all properties, and since the Protovis inheritance chain is
<span class='line'>141</span>    * independent of the JavaScript inheritance chain. For example, anchors
<span class='line'>142</span>    * define a "name" property that is evaluated on derived marks, even though
<span class='line'>143</span>    * those marks don't normally have a name.
<span class='line'>144</span>    */</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT">  </span><span class="NAME">pv.Mark.prototype.propertyMethod</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pv.Mark.cast</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">cast</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>147</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>148</span> 
<span class='line'>149</span> </span><span class="COMM">/**
<span class='line'>150</span>  * @private Defines a setter-getter for the specified property.
<span class='line'>151</span>  *
<span class='line'>152</span>  * &lt;p>If a cast function has been assigned to the specified property name, the
<span class='line'>153</span>  * property function is wrapped by the cast function, or, if a constant is
<span class='line'>154</span>  * specified, the constant is immediately cast. Note, however, that if the
<span class='line'>155</span>  * property value is null, the cast function is not invoked.
<span class='line'>156</span>  *
<span class='line'>157</span>  * @param {string} name the property name.
<span class='line'>158</span>  * @param {boolean} [def] whether is a property or a def.
<span class='line'>159</span>  * @param {function} [cast] the cast function for this property.
<span class='line'>160</span>  */</span><span class="WHIT">
<span class='line'>161</span> </span><span class="NAME">pv.Mark.prototype.propertyMethod</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">def</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">cast</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>162</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">cast</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">cast</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.Mark.cast</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT">  </span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">v</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>164</span> 
<span class='line'>165</span> </span><span class="WHIT">      </span><span class="COMM">/* If this is a def, use it rather than property. */</span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">def</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">this.scene</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">defs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.scene.defs</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>168</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT">          </span><span class="NAME">defs</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>170</span> </span><span class="WHIT">            </span><span class="NAME">id</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pv.id</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>171</span> </span><span class="WHIT">            </span><span class="NAME">value</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">cast</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">cast</span><span class="PUNC">(</span><span class="NAME">v</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">v</span><span class="WHIT">
<span class='line'>172</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>173</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>174</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>175</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">defs</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">defs</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>176</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>177</span> 
<span class='line'>178</span> </span><span class="WHIT">      </span><span class="COMM">/* If arguments are specified, set the property value. */</span><span class="WHIT">
<span class='line'>179</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>180</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">def</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"function"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>181</span> </span><span class="WHIT">        </span><span class="NAME">this.propertyValue</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">cast</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">v.apply</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>183</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">cast</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">cast</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">cast</span><span class="PUNC">(</span><span class="NAME">v</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>185</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>187</span> 
<span class='line'>188</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.instance</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>189</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>190</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>191</span> 
<span class='line'>192</span> </span><span class="COMM">/** @private Sets the value of the property &lt;i>name&lt;/i> to &lt;i>v&lt;/i>. */</span><span class="WHIT">
<span class='line'>193</span> </span><span class="NAME">pv.Mark.prototype.propertyValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>194</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">properties</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.$properties</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">name</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pv.id</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>195</span> </span><span class="WHIT">  </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">properties.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">properties</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT">      </span><span class="NAME">properties.splice</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT">      </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>201</span> </span><span class="WHIT">  </span><span class="NAME">properties.push</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>202</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>203</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>204</span> 
<span class='line'>205</span> </span><span class="COMM">/* Define all global properties. */</span><span class="WHIT">
<span class='line'>206</span> </span><span class="NAME">pv.Mark.prototype</span><span class="WHIT">
<span class='line'>207</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"data"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>208</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"visible"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Boolean</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>209</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"left"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>210</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"right"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>211</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"top"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>212</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"bottom"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>213</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"cursor"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>214</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"title"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>215</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"reverse"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Boolean</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>216</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"antialias"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Boolean</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>217</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"events"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>218</span> 
<span class='line'>219</span> </span><span class="COMM">/**
<span class='line'>220</span>  * The mark type; a lower camelCase name. The type name controls rendering
<span class='line'>221</span>  * behavior, and unless the rendering engine is extended, must be one of the
<span class='line'>222</span>  * built-in concrete mark types: area, bar, dot, image, label, line, panel,
<span class='line'>223</span>  * rule, or wedge.
<span class='line'>224</span>  *
<span class='line'>225</span>  * @type string
<span class='line'>226</span>  * @name pv.Mark.prototype.type
<span class='line'>227</span>  */</span><span class="WHIT">
<span class='line'>228</span> 
<span class='line'>229</span> </span><span class="COMM">/**
<span class='line'>230</span>  * The mark prototype, possibly undefined, from which to inherit property
<span class='line'>231</span>  * functions. The mark prototype is not necessarily of the same type as this
<span class='line'>232</span>  * mark. Any properties defined on this mark will override properties inherited
<span class='line'>233</span>  * either from the prototype or from the type-specific defaults.
<span class='line'>234</span>  *
<span class='line'>235</span>  * @type pv.Mark
<span class='line'>236</span>  * @name pv.Mark.prototype.proto
<span class='line'>237</span>  */</span><span class="WHIT">
<span class='line'>238</span> 
<span class='line'>239</span> </span><span class="COMM">/**
<span class='line'>240</span>  * The enclosing parent panel. The parent panel is generally undefined only for
<span class='line'>241</span>  * the root panel; however, it is possible to create "offscreen" marks that are
<span class='line'>242</span>  * used only for inheritance purposes.
<span class='line'>243</span>  *
<span class='line'>244</span>  * @type pv.Panel
<span class='line'>245</span>  * @name pv.Mark.prototype.parent
<span class='line'>246</span>  */</span><span class="WHIT">
<span class='line'>247</span> 
<span class='line'>248</span> </span><span class="COMM">/**
<span class='line'>249</span>  * The child index. -1 if the enclosing parent panel is null; otherwise, the
<span class='line'>250</span>  * zero-based index of this mark into the parent panel's &lt;tt>children&lt;/tt> array.
<span class='line'>251</span>  *
<span class='line'>252</span>  * @type number
<span class='line'>253</span>  */</span><span class="WHIT">
<span class='line'>254</span> </span><span class="NAME">pv.Mark.prototype.childIndex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>255</span> 
<span class='line'>256</span> </span><span class="COMM">/**
<span class='line'>257</span>  * The mark index. The value of this field depends on which instance (i.e.,
<span class='line'>258</span>  * which element of the data array) is currently being evaluated. During the
<span class='line'>259</span>  * build phase, the index is incremented over each datum; when handling events,
<span class='line'>260</span>  * the index is set to the instance that triggered the event.
<span class='line'>261</span>  *
<span class='line'>262</span>  * @type number
<span class='line'>263</span>  */</span><span class="WHIT">
<span class='line'>264</span> </span><span class="NAME">pv.Mark.prototype.index</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>265</span> 
<span class='line'>266</span> </span><span class="COMM">/**
<span class='line'>267</span>  * The current scale factor, based on any enclosing transforms. The current
<span class='line'>268</span>  * scale can be used to create scale-independent graphics. For example, to
<span class='line'>269</span>  * define a dot that has a radius of 10 irrespective of any zooming, say:
<span class='line'>270</span>  *
<span class='line'>271</span>  * &lt;pre>dot.radius(function() 10 / this.scale)&lt;/pre>
<span class='line'>272</span>  *
<span class='line'>273</span>  * Note that the stroke width and font size are defined irrespective of scale
<span class='line'>274</span>  * (i.e., in screen space) already. Also note that when a transform is applied
<span class='line'>275</span>  * to a panel, the scale affects only the child marks, not the panel itself.
<span class='line'>276</span>  *
<span class='line'>277</span>  * @type number
<span class='line'>278</span>  * @see pv.Panel#transform
<span class='line'>279</span>  */</span><span class="WHIT">
<span class='line'>280</span> </span><span class="NAME">pv.Mark.prototype.scale</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>281</span> 
<span class='line'>282</span> </span><span class="COMM">/**
<span class='line'>283</span>  * @private The scene graph. The scene graph is an array of objects; each object
<span class='line'>284</span>  * (or "node") corresponds to an instance of this mark and an element in the
<span class='line'>285</span>  * data array. The scene graph can be traversed to lookup previously-evaluated
<span class='line'>286</span>  * properties.
<span class='line'>287</span>  *
<span class='line'>288</span>  * @name pv.Mark.prototype.scene
<span class='line'>289</span>  */</span><span class="WHIT">
<span class='line'>290</span> 
<span class='line'>291</span> </span><span class="COMM">/**
<span class='line'>292</span>  * The root parent panel. This may be undefined for "offscreen" marks that are
<span class='line'>293</span>  * created for inheritance purposes only.
<span class='line'>294</span>  *
<span class='line'>295</span>  * @type pv.Panel
<span class='line'>296</span>  * @name pv.Mark.prototype.root
<span class='line'>297</span>  */</span><span class="WHIT">
<span class='line'>298</span> 
<span class='line'>299</span> </span><span class="COMM">/**
<span class='line'>300</span>  * The data property; an array of objects. The size of the array determines the
<span class='line'>301</span>  * number of marks that will be instantiated; each element in the array will be
<span class='line'>302</span>  * passed to property functions to compute the property values. Typically, the
<span class='line'>303</span>  * data property is specified as a constant array, such as
<span class='line'>304</span>  *
<span class='line'>305</span>  * &lt;pre>m.data([1, 2, 3, 4, 5]);&lt;/pre>
<span class='line'>306</span>  *
<span class='line'>307</span>  * However, it is perfectly acceptable to define the data property as a
<span class='line'>308</span>  * function. This function might compute the data dynamically, allowing
<span class='line'>309</span>  * different data to be used per enclosing panel. For instance, in the stacked
<span class='line'>310</span>  * area graph example (see {@link #scene}), the data function on the area mark
<span class='line'>311</span>  * dereferences each series.
<span class='line'>312</span>  *
<span class='line'>313</span>  * @type array
<span class='line'>314</span>  * @name pv.Mark.prototype.data
<span class='line'>315</span>  */</span><span class="WHIT">
<span class='line'>316</span> 
<span class='line'>317</span> </span><span class="COMM">/**
<span class='line'>318</span>  * The visible property; a boolean determining whether or not the mark instance
<span class='line'>319</span>  * is visible. If a mark instance is not visible, its other properties will not
<span class='line'>320</span>  * be evaluated. Similarly, for panels no child marks will be rendered.
<span class='line'>321</span>  *
<span class='line'>322</span>  * @type boolean
<span class='line'>323</span>  * @name pv.Mark.prototype.visible
<span class='line'>324</span>  */</span><span class="WHIT">
<span class='line'>325</span> 
<span class='line'>326</span> </span><span class="COMM">/**
<span class='line'>327</span>  * The left margin; the distance, in pixels, between the left edge of the
<span class='line'>328</span>  * enclosing panel and the left edge of this mark. Note that in some cases this
<span class='line'>329</span>  * property may be redundant with the right property, or with the conjunction of
<span class='line'>330</span>  * right and width.
<span class='line'>331</span>  *
<span class='line'>332</span>  * @type number
<span class='line'>333</span>  * @name pv.Mark.prototype.left
<span class='line'>334</span>  */</span><span class="WHIT">
<span class='line'>335</span> 
<span class='line'>336</span> </span><span class="COMM">/**
<span class='line'>337</span>  * The right margin; the distance, in pixels, between the right edge of the
<span class='line'>338</span>  * enclosing panel and the right edge of this mark. Note that in some cases this
<span class='line'>339</span>  * property may be redundant with the left property, or with the conjunction of
<span class='line'>340</span>  * left and width.
<span class='line'>341</span>  *
<span class='line'>342</span>  * @type number
<span class='line'>343</span>  * @name pv.Mark.prototype.right
<span class='line'>344</span>  */</span><span class="WHIT">
<span class='line'>345</span> 
<span class='line'>346</span> </span><span class="COMM">/**
<span class='line'>347</span>  * The top margin; the distance, in pixels, between the top edge of the
<span class='line'>348</span>  * enclosing panel and the top edge of this mark. Note that in some cases this
<span class='line'>349</span>  * property may be redundant with the bottom property, or with the conjunction
<span class='line'>350</span>  * of bottom and height.
<span class='line'>351</span>  *
<span class='line'>352</span>  * @type number
<span class='line'>353</span>  * @name pv.Mark.prototype.top
<span class='line'>354</span>  */</span><span class="WHIT">
<span class='line'>355</span> 
<span class='line'>356</span> </span><span class="COMM">/**
<span class='line'>357</span>  * The bottom margin; the distance, in pixels, between the bottom edge of the
<span class='line'>358</span>  * enclosing panel and the bottom edge of this mark. Note that in some cases
<span class='line'>359</span>  * this property may be redundant with the top property, or with the conjunction
<span class='line'>360</span>  * of top and height.
<span class='line'>361</span>  *
<span class='line'>362</span>  * @type number
<span class='line'>363</span>  * @name pv.Mark.prototype.bottom
<span class='line'>364</span>  */</span><span class="WHIT">
<span class='line'>365</span> 
<span class='line'>366</span> </span><span class="COMM">/**
<span class='line'>367</span>  * The cursor property; corresponds to the CSS cursor property. This is
<span class='line'>368</span>  * typically used in conjunction with event handlers to indicate interactivity.
<span class='line'>369</span>  *
<span class='line'>370</span>  * @type string
<span class='line'>371</span>  * @name pv.Mark.prototype.cursor
<span class='line'>372</span>  * @see &lt;a href="http://www.w3.org/TR/CSS2/ui.html#propdef-cursor">CSS2 cursor&lt;/a>
<span class='line'>373</span>  */</span><span class="WHIT">
<span class='line'>374</span> 
<span class='line'>375</span> </span><span class="COMM">/**
<span class='line'>376</span>  * The title property; corresponds to the HTML/SVG title property, allowing the
<span class='line'>377</span>  * general of simple plain text tooltips.
<span class='line'>378</span>  *
<span class='line'>379</span>  * @type string
<span class='line'>380</span>  * @name pv.Mark.prototype.title
<span class='line'>381</span>  */</span><span class="WHIT">
<span class='line'>382</span> 
<span class='line'>383</span> </span><span class="COMM">/**
<span class='line'>384</span>  * The events property; corresponds to the SVG pointer-events property,
<span class='line'>385</span>  * specifying how the mark should participate in mouse events. The default value
<span class='line'>386</span>  * is "painted". Supported values are:
<span class='line'>387</span>  *
<span class='line'>388</span>  * &lt;p>"painted": The given mark may receive events when the mouse is over a
<span class='line'>389</span>  * "painted" area. The painted areas are the interior (i.e., fill) of the mark
<span class='line'>390</span>  * if a 'fillStyle' is specified, and the perimeter (i.e., stroke) of the mark
<span class='line'>391</span>  * if a 'strokeStyle' is specified.
<span class='line'>392</span>  *
<span class='line'>393</span>  * &lt;p>"all": The given mark may receive events when the mouse is over either the
<span class='line'>394</span>  * interior (i.e., fill) or the perimeter (i.e., stroke) of the mark, regardless
<span class='line'>395</span>  * of the specified fillStyle and strokeStyle.
<span class='line'>396</span>  *
<span class='line'>397</span>  * &lt;p>"none": The given mark may not receive events.
<span class='line'>398</span>  *
<span class='line'>399</span>  * @type string
<span class='line'>400</span>  * @name pv.Mark.prototype.events
<span class='line'>401</span>  */</span><span class="WHIT">
<span class='line'>402</span> 
<span class='line'>403</span> </span><span class="COMM">/**
<span class='line'>404</span>  * The reverse property; a boolean determining whether marks are ordered from
<span class='line'>405</span>  * front-to-back or back-to-front. SVG does not support explicit z-ordering;
<span class='line'>406</span>  * shapes are rendered in the order they appear. Thus, by default, marks are
<span class='line'>407</span>  * rendered in data order. Setting the reverse property to false reverses the
<span class='line'>408</span>  * order in which they are rendered; however, the properties are still evaluated
<span class='line'>409</span>  * (i.e., built) in forward order.
<span class='line'>410</span>  *
<span class='line'>411</span>  * @type boolean
<span class='line'>412</span>  * @name pv.Mark.prototype.reverse
<span class='line'>413</span>  */</span><span class="WHIT">
<span class='line'>414</span> 
<span class='line'>415</span> </span><span class="COMM">/**
<span class='line'>416</span>  * Default properties for all mark types. By default, the data array is the
<span class='line'>417</span>  * parent data as a single-element array; if the data property is not specified,
<span class='line'>418</span>  * this causes each mark to be instantiated as a singleton with the parents
<span class='line'>419</span>  * datum. The visible property is true by default, and the reverse property is
<span class='line'>420</span>  * false.
<span class='line'>421</span>  *
<span class='line'>422</span>  * @type pv.Mark
<span class='line'>423</span>  */</span><span class="WHIT">
<span class='line'>424</span> </span><span class="NAME">pv.Mark.prototype.defaults</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">pv.Mark</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>425</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">data</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">d</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>426</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">visible</span><span class="PUNC">(</span><span class="KEYW">true</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>427</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">antialias</span><span class="PUNC">(</span><span class="KEYW">true</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>428</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">events</span><span class="PUNC">(</span><span class="STRN">"painted"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>429</span> 
<span class='line'>430</span> </span><span class="COMM">/**
<span class='line'>431</span>  * Sets the prototype of this mark to the specified mark. Any properties not
<span class='line'>432</span>  * defined on this mark may be inherited from the specified prototype mark, or
<span class='line'>433</span>  * its prototype, and so on. The prototype mark need not be the same type of
<span class='line'>434</span>  * mark as this mark. (Note that for inheritance to be useful, properties with
<span class='line'>435</span>  * the same name on different mark types should have equivalent meaning.)
<span class='line'>436</span>  *
<span class='line'>437</span>  * @param {pv.Mark} proto the new prototype.
<span class='line'>438</span>  * @returns {pv.Mark} this mark.
<span class='line'>439</span>  * @see #add
<span class='line'>440</span>  */</span><span class="WHIT">
<span class='line'>441</span> </span><span class="NAME">pv.Mark.prototype.extend</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">proto</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>442</span> </span><span class="WHIT">  </span><span class="NAME">this.proto</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">proto</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>443</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>444</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>445</span> 
<span class='line'>446</span> </span><span class="COMM">/**
<span class='line'>447</span>  * Adds a new mark of the specified type to the enclosing parent panel, whilst
<span class='line'>448</span>  * simultaneously setting the prototype of the new mark to be this mark.
<span class='line'>449</span>  *
<span class='line'>450</span>  * @param {function} type the type of mark to add; a constructor, such as
<span class='line'>451</span>  * &lt;tt>pv.Bar&lt;/tt>.
<span class='line'>452</span>  * @returns {pv.Mark} the new mark.
<span class='line'>453</span>  * @see #extend
<span class='line'>454</span>  */</span><span class="WHIT">
<span class='line'>455</span> </span><span class="NAME">pv.Mark.prototype.add</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>456</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.parent.add</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">extend</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>457</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>458</span> 
<span class='line'>459</span> </span><span class="COMM">/**
<span class='line'>460</span>  * Defines a custom property on this mark. Custom properties are currently
<span class='line'>461</span>  * fixed, in that they are initialized once per mark set (i.e., per parent panel
<span class='line'>462</span>  * instance). Custom properties can be used to store local state for the mark,
<span class='line'>463</span>  * such as data needed by other properties (e.g., a custom scale) or interaction
<span class='line'>464</span>  * state.
<span class='line'>465</span>  *
<span class='line'>466</span>  * &lt;p>WARNING We plan on changing this feature in a future release to define
<span class='line'>467</span>  * standard properties, as opposed to &lt;i>fixed&lt;/i> properties that behave
<span class='line'>468</span>  * idiosyncratically within event handlers. Furthermore, we recommend storing
<span class='line'>469</span>  * state in an external data structure, rather than tying it to the
<span class='line'>470</span>  * visualization specification as with defs.
<span class='line'>471</span>  *
<span class='line'>472</span>  * @param {string} name the name of the local variable.
<span class='line'>473</span>  * @param {function} [v] an optional initializer; may be a constant or a
<span class='line'>474</span>  * function.
<span class='line'>475</span>  */</span><span class="WHIT">
<span class='line'>476</span> </span><span class="NAME">pv.Mark.prototype.def</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>477</span> </span><span class="WHIT">  </span><span class="NAME">this.propertyMethod</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>478</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>479</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>480</span> 
<span class='line'>481</span> </span><span class="COMM">/**
<span class='line'>482</span>  * Returns an anchor with the specified name. All marks support the five
<span class='line'>483</span>  * standard anchor names:&lt;ul>
<span class='line'>484</span>  *
<span class='line'>485</span>  * &lt;li>top
<span class='line'>486</span>  * &lt;li>left
<span class='line'>487</span>  * &lt;li>center
<span class='line'>488</span>  * &lt;li>bottom
<span class='line'>489</span>  * &lt;li>right
<span class='line'>490</span>  *
<span class='line'>491</span>  * &lt;/ul>In addition to positioning properties (left, right, top bottom), the
<span class='line'>492</span>  * anchors support text rendering properties (text-align, text-baseline). Text is
<span class='line'>493</span>  * rendered to appear inside the mark by default.
<span class='line'>494</span>  *
<span class='line'>495</span>  * &lt;p>To facilitate stacking, anchors are defined in terms of their opposite
<span class='line'>496</span>  * edge. For example, the top anchor defines the bottom property, such that the
<span class='line'>497</span>  * mark extends upwards; the bottom anchor instead defines the top property,
<span class='line'>498</span>  * such that the mark extends downwards. See also {@link pv.Layout.Stack}.
<span class='line'>499</span>  *
<span class='line'>500</span>  * &lt;p>While anchor names are typically constants, the anchor name is a true
<span class='line'>501</span>  * property, which means you can specify a function to compute the anchor name
<span class='line'>502</span>  * dynamically. See the {@link pv.Anchor#name} property for details.
<span class='line'>503</span>  *
<span class='line'>504</span>  * @param {string} name the anchor name; either a string or a property function.
<span class='line'>505</span>  * @returns {pv.Anchor} the new anchor.
<span class='line'>506</span>  */</span><span class="WHIT">
<span class='line'>507</span> </span><span class="NAME">pv.Mark.prototype.anchor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>508</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">target</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">scene</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>509</span> 
<span class='line'>510</span> </span><span class="WHIT">  </span><span class="COMM">/* Default anchor name. */</span><span class="WHIT">
<span class='line'>511</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">name</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"center"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>512</span> 
<span class='line'>513</span> </span><span class="WHIT">  </span><span class="COMM">/** @private Find the instances of target that match source. */</span><span class="WHIT">
<span class='line'>514</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">instances</span><span class="PUNC">(</span><span class="NAME">source</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>515</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">mark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">index</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>516</span> 
<span class='line'>517</span> </span><span class="WHIT">    </span><span class="COMM">/* Mirrored descent. */</span><span class="WHIT">
<span class='line'>518</span> </span><span class="WHIT">    </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">scene</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mark.scene</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>519</span> </span><span class="WHIT">      </span><span class="NAME">source</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">source.parent</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>520</span> </span><span class="WHIT">      </span><span class="NAME">index.push</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="NAME">index</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">source.index</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">childIndex</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">mark.childIndex</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>521</span> </span><span class="WHIT">      </span><span class="NAME">mark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mark.parent</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>522</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>523</span> </span><span class="WHIT">    </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">index.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>524</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">index.pop</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>525</span> </span><span class="WHIT">      </span><span class="NAME">scene</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scene</span><span class="PUNC">[</span><span class="NAME">i.index</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">children</span><span class="PUNC">[</span><span class="NAME">i.childIndex</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>526</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>527</span> 
<span class='line'>528</span> </span><span class="WHIT">    </span><span class="COMM">/*
<span class='line'>529</span>      * When the anchor target is also an ancestor, as in the case of adding
<span class='line'>530</span>      * to a panel anchor, only generate one instance per panel. Also, set
<span class='line'>531</span>      * the margins to zero, since they are offset by the enclosing panel.
<span class='line'>532</span>      */</span><span class="WHIT">
<span class='line'>533</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">target.hasOwnProperty</span><span class="PUNC">(</span><span class="STRN">"index"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>534</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.extend</span><span class="PUNC">(</span><span class="NAME">scene</span><span class="PUNC">[</span><span class="NAME">target.index</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>535</span> </span><span class="WHIT">      </span><span class="NAME">s.right</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.top</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.left</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.bottom</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>536</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">s</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>537</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>538</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">scene</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>539</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>540</span> 
<span class='line'>541</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">pv.Anchor</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>542</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">name</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>543</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">def</span><span class="PUNC">(</span><span class="STRN">"$mark.anchor"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>544</span> </span><span class="WHIT">        </span><span class="NAME">scene</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.scene.target</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">instances</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>545</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>546</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">data</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>547</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">scene.map</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s.data</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>548</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>549</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">visible</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>550</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">scene</span><span class="PUNC">[</span><span class="NAME">this.index</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">visible</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>551</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>552</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">left</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>553</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scene</span><span class="PUNC">[</span><span class="NAME">this.index</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.width</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>554</span> </span><span class="WHIT">        </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.name</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>555</span> </span><span class="WHIT">          </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"bottom"</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>556</span> </span><span class="WHIT">          </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"top"</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>557</span> </span><span class="WHIT">          </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"center"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s.left</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>558</span> </span><span class="WHIT">          </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"left"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>559</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>560</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s.left</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">w</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>561</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>562</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">top</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>563</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scene</span><span class="PUNC">[</span><span class="NAME">this.index</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.height</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>564</span> </span><span class="WHIT">        </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.name</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>565</span> </span><span class="WHIT">          </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"left"</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>566</span> </span><span class="WHIT">          </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"right"</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>567</span> </span><span class="WHIT">          </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"center"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s.top</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>568</span> </span><span class="WHIT">          </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"top"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>569</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>570</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s.top</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>571</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>572</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">right</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>573</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scene</span><span class="PUNC">[</span><span class="NAME">this.index</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>574</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.name</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"left"</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">s.right</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.width</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>575</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>576</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">bottom</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>577</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scene</span><span class="PUNC">[</span><span class="NAME">this.index</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>578</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.name</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"top"</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">s.bottom</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.height</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>579</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>580</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">textAlign</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>581</span> </span><span class="WHIT">        </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.name</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>582</span> </span><span class="WHIT">          </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"bottom"</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>583</span> </span><span class="WHIT">          </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"top"</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>584</span> </span><span class="WHIT">          </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"center"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"center"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>585</span> </span><span class="WHIT">          </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"right"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"right"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>586</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>587</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"left"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>588</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>589</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">textBaseline</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>590</span> </span><span class="WHIT">        </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.name</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>591</span> </span><span class="WHIT">          </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"right"</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>592</span> </span><span class="WHIT">          </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"left"</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>593</span> </span><span class="WHIT">          </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"center"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"middle"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>594</span> </span><span class="WHIT">          </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"top"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"top"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>595</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>596</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"bottom"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>597</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>598</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>599</span> 
<span class='line'>600</span> </span><span class="COMM">/**
<span class='line'>601</span>  * Returns the anchor target of this mark, if it is derived from an anchor;
<span class='line'>602</span>  * otherwise returns null. For example, if a label is derived from a bar anchor,
<span class='line'>603</span>  *
<span class='line'>604</span>  * &lt;pre>bar.anchor("top").add(pv.Label);&lt;/pre>
<span class='line'>605</span>  *
<span class='line'>606</span>  * then property functions on the label can refer to the bar via the
<span class='line'>607</span>  * &lt;tt>anchorTarget&lt;/tt> method. This method is also useful for mark types
<span class='line'>608</span>  * defining properties on custom anchors.
<span class='line'>609</span>  *
<span class='line'>610</span>  * @returns {pv.Mark} the anchor target of this mark; possibly null.
<span class='line'>611</span>  */</span><span class="WHIT">
<span class='line'>612</span> </span><span class="NAME">pv.Mark.prototype.anchorTarget</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>613</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.proto.anchorTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>614</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>615</span> 
<span class='line'>616</span> </span><span class="COMM">/**
<span class='line'>617</span>  * Alias for setting the left, right, top and bottom properties simultaneously.
<span class='line'>618</span>  *
<span class='line'>619</span>  * @see #left
<span class='line'>620</span>  * @see #right
<span class='line'>621</span>  * @see #top
<span class='line'>622</span>  * @see #bottom
<span class='line'>623</span>  * @returns {pv.Mark} this.
<span class='line'>624</span>  */</span><span class="WHIT">
<span class='line'>625</span> </span><span class="NAME">pv.Mark.prototype.margin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>626</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.left</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">right</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">top</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">bottom</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>627</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>628</span> 
<span class='line'>629</span> </span><span class="COMM">/**
<span class='line'>630</span>  * @private Returns the current instance of this mark in the scene graph. This
<span class='line'>631</span>  * is typically equivalent to &lt;tt>this.scene[this.index]&lt;/tt>, however if the
<span class='line'>632</span>  * scene or index is unset, the default instance of the mark is returned. If no
<span class='line'>633</span>  * default is set, the default is the last instance. Similarly, if the scene or
<span class='line'>634</span>  * index of the parent panel is unset, the default instance of this mark in the
<span class='line'>635</span>  * last instance of the enclosing panel is returned, and so on.
<span class='line'>636</span>  *
<span class='line'>637</span>  * @returns a node in the scene graph.
<span class='line'>638</span>  */</span><span class="WHIT">
<span class='line'>639</span> </span><span class="NAME">pv.Mark.prototype.instance</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">defaultIndex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>640</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">scene</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.scene</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">this.parent.instance</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">children</span><span class="PUNC">[</span><span class="NAME">this.childIndex</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>641</span> </span><span class="WHIT">      </span><span class="NAME">index</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">arguments.length</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">this.hasOwnProperty</span><span class="PUNC">(</span><span class="STRN">"index"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">this.index</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">defaultIndex</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>642</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">scene</span><span class="PUNC">[</span><span class="NAME">index</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">scene.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">index</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>643</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>644</span> 
<span class='line'>645</span> </span><span class="COMM">/**
<span class='line'>646</span>  * @private Returns the first instance of this mark in the scene graph. This
<span class='line'>647</span>  * method can only be called when the mark is bound to the scene graph (for
<span class='line'>648</span>  * example, from an event handler, or within a property function).
<span class='line'>649</span>  *
<span class='line'>650</span>  * @returns a node in the scene graph.
<span class='line'>651</span>  */</span><span class="WHIT">
<span class='line'>652</span> </span><span class="NAME">pv.Mark.prototype.first</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>653</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.scene</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>654</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>655</span> 
<span class='line'>656</span> </span><span class="COMM">/**
<span class='line'>657</span>  * @private Returns the last instance of this mark in the scene graph. This
<span class='line'>658</span>  * method can only be called when the mark is bound to the scene graph (for
<span class='line'>659</span>  * example, from an event handler, or within a property function). In addition,
<span class='line'>660</span>  * note that mark instances are built sequentially, so the last instance of this
<span class='line'>661</span>  * mark may not yet be constructed.
<span class='line'>662</span>  *
<span class='line'>663</span>  * @returns a node in the scene graph.
<span class='line'>664</span>  */</span><span class="WHIT">
<span class='line'>665</span> </span><span class="NAME">pv.Mark.prototype.last</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>666</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.scene</span><span class="PUNC">[</span><span class="NAME">this.scene.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>667</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>668</span> 
<span class='line'>669</span> </span><span class="COMM">/**
<span class='line'>670</span>  * @private Returns the previous instance of this mark in the scene graph, or
<span class='line'>671</span>  * null if this is the first instance.
<span class='line'>672</span>  *
<span class='line'>673</span>  * @returns a node in the scene graph, or null.
<span class='line'>674</span>  */</span><span class="WHIT">
<span class='line'>675</span> </span><span class="NAME">pv.Mark.prototype.sibling</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>676</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.index</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">this.scene</span><span class="PUNC">[</span><span class="NAME">this.index</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>677</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>678</span> 
<span class='line'>679</span> </span><span class="COMM">/**
<span class='line'>680</span>  * @private Returns the current instance in the scene graph of this mark, in the
<span class='line'>681</span>  * previous instance of the enclosing parent panel. May return null if this
<span class='line'>682</span>  * instance could not be found.
<span class='line'>683</span>  *
<span class='line'>684</span>  * @returns a node in the scene graph, or null.
<span class='line'>685</span>  */</span><span class="WHIT">
<span class='line'>686</span> </span><span class="NAME">pv.Mark.prototype.cousin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>687</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.parent</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">p.sibling</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>688</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">s.children</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">s.children</span><span class="PUNC">[</span><span class="NAME">this.childIndex</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">this.index</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>689</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>690</span> 
<span class='line'>691</span> </span><span class="COMM">/**
<span class='line'>692</span>  * Renders this mark, including recursively rendering all child marks if this is
<span class='line'>693</span>  * a panel. This method finds all instances of this mark and renders them. This
<span class='line'>694</span>  * method descends recursively to the level of the mark to be rendered, finding
<span class='line'>695</span>  * all visible instances of the mark. After the marks are rendered, the scene
<span class='line'>696</span>  * and index attributes are removed from the mark to restore them to a clean
<span class='line'>697</span>  * state.
<span class='line'>698</span>  *
<span class='line'>699</span>  * &lt;p>If an enclosing panel has an index property set (as is the case inside in
<span class='line'>700</span>  * an event handler), then only instances of this mark inside the given instance
<span class='line'>701</span>  * of the panel will be rendered; otherwise, all visible instances of the mark
<span class='line'>702</span>  * will be rendered.
<span class='line'>703</span>  */</span><span class="WHIT">
<span class='line'>704</span> </span><span class="NAME">pv.Mark.prototype.render</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>705</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">parent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.parent</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>706</span> </span><span class="WHIT">      </span><span class="NAME">stack</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.Mark.stack</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>707</span> 
<span class='line'>708</span> </span><span class="WHIT">  </span><span class="COMM">/* For the first render, take it from the top. */</span><span class="WHIT">
<span class='line'>709</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">parent</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">this.root.scene</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>710</span> </span><span class="WHIT">    </span><span class="NAME">this.root.render</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>711</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>712</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>713</span> 
<span class='line'>714</span> </span><span class="WHIT">  </span><span class="COMM">/* Record the path to this mark. */</span><span class="WHIT">
<span class='line'>715</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">indexes</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>716</span> </span><span class="WHIT">  </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">mark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">mark.parent</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">mark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mark.parent</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>717</span> </span><span class="WHIT">    </span><span class="NAME">indexes.unshift</span><span class="PUNC">(</span><span class="NAME">mark.childIndex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>718</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>719</span> 
<span class='line'>720</span> </span><span class="WHIT">  </span><span class="COMM">/** @private */</span><span class="WHIT">
<span class='line'>721</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">render</span><span class="PUNC">(</span><span class="NAME">mark</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">depth</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>722</span> </span><span class="WHIT">    </span><span class="NAME">mark.scale</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>723</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">depth</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">indexes.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>724</span> </span><span class="WHIT">      </span><span class="NAME">stack.unshift</span><span class="PUNC">(</span><span class="KEYW">null</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>725</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">mark.hasOwnProperty</span><span class="PUNC">(</span><span class="STRN">"index"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>726</span> </span><span class="WHIT">        </span><span class="NAME">renderInstance</span><span class="PUNC">(</span><span class="NAME">mark</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">depth</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>727</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>728</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mark.scene.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>729</span> </span><span class="WHIT">          </span><span class="NAME">mark.index</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>730</span> </span><span class="WHIT">          </span><span class="NAME">renderInstance</span><span class="PUNC">(</span><span class="NAME">mark</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">depth</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>731</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>732</span> </span><span class="WHIT">        </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">mark.index</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>733</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>734</span> </span><span class="WHIT">      </span><span class="NAME">stack.shift</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>735</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>736</span> </span><span class="WHIT">      </span><span class="NAME">mark.build</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>737</span> 
<span class='line'>738</span> </span><span class="WHIT">      </span><span class="COMM">/*
<span class='line'>739</span>        * In the update phase, the scene is rendered by creating and updating
<span class='line'>740</span>        * elements and attributes in the SVG image. No properties are evaluated
<span class='line'>741</span>        * during the update phase; instead the values computed previously in the
<span class='line'>742</span>        * build phase are simply translated into SVG. The update phase is
<span class='line'>743</span>        * decoupled (see pv.Scene) to allow different rendering engines.
<span class='line'>744</span>        */</span><span class="WHIT">
<span class='line'>745</span> </span><span class="WHIT">      </span><span class="NAME">pv.Scene.scale</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>746</span> </span><span class="WHIT">      </span><span class="NAME">pv.Scene.updateAll</span><span class="PUNC">(</span><span class="NAME">mark.scene</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>747</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>748</span> </span><span class="WHIT">    </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">mark.scale</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>749</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>750</span> 
<span class='line'>751</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>752</span>    * @private Recursively renders the current instance of the specified mark.
<span class='line'>753</span>    * This is slightly tricky because `index` and `scene` properties may or may
<span class='line'>754</span>    * not already be set; if they are set, it means we are rendering only a
<span class='line'>755</span>    * specific instance; if they are unset, we are rendering all instances.
<span class='line'>756</span>    * Furthermore, we must preserve the original context of these properties when
<span class='line'>757</span>    * rendering completes.
<span class='line'>758</span>    *
<span class='line'>759</span>    * &lt;p>Another tricky aspect is that the `scene` attribute should be set for
<span class='line'>760</span>    * any preceding children, so as to allow property chaining. This is
<span class='line'>761</span>    * consistent with first-pass rendering.
<span class='line'>762</span>    */</span><span class="WHIT">
<span class='line'>763</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">renderInstance</span><span class="PUNC">(</span><span class="NAME">mark</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">depth</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>764</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mark.scene</span><span class="PUNC">[</span><span class="NAME">mark.index</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>765</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.visible</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>766</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">childIndex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">indexes</span><span class="PUNC">[</span><span class="NAME">depth</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>767</span> </span><span class="WHIT">          </span><span class="NAME">child</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mark.children</span><span class="PUNC">[</span><span class="NAME">childIndex</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>768</span> 
<span class='line'>769</span> </span><span class="WHIT">      </span><span class="COMM">/* Set preceding child scenes. */</span><span class="WHIT">
<span class='line'>770</span> </span><span class="WHIT">      </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">childIndex</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>771</span> </span><span class="WHIT">        </span><span class="NAME">mark.children</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">scene</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.children</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>772</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>773</span> 
<span class='line'>774</span> </span><span class="WHIT">      </span><span class="COMM">/* Set current child scene, if necessary. */</span><span class="WHIT">
<span class='line'>775</span> </span><span class="WHIT">      </span><span class="NAME">stack</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.data</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>776</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">child.scene</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>777</span> </span><span class="WHIT">        </span><span class="NAME">render</span><span class="PUNC">(</span><span class="NAME">child</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">depth</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">s.transform.k</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>778</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>779</span> </span><span class="WHIT">        </span><span class="NAME">child.scene</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.children</span><span class="PUNC">[</span><span class="NAME">childIndex</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>780</span> </span><span class="WHIT">        </span><span class="NAME">render</span><span class="PUNC">(</span><span class="NAME">child</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">depth</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">s.transform.k</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>781</span> </span><span class="WHIT">        </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">child.scene</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>782</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>783</span> 
<span class='line'>784</span> </span><span class="WHIT">      </span><span class="COMM">/* Clear preceding child scenes. */</span><span class="WHIT">
<span class='line'>785</span> </span><span class="WHIT">      </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">childIndex</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>786</span> </span><span class="WHIT">        </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">mark.children</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">scene</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>787</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>788</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>789</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>790</span> 
<span class='line'>791</span> </span><span class="WHIT">  </span><span class="COMM">/* Bind this mark's property definitions. */</span><span class="WHIT">
<span class='line'>792</span> </span><span class="WHIT">  </span><span class="NAME">this.bind</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>793</span> 
<span class='line'>794</span> </span><span class="WHIT">  </span><span class="COMM">/* The render context is the first ancestor with an explicit index. */</span><span class="WHIT">
<span class='line'>795</span> </span><span class="WHIT">  </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">parent</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">parent.hasOwnProperty</span><span class="PUNC">(</span><span class="STRN">"index"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">parent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parent.parent</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>796</span> 
<span class='line'>797</span> </span><span class="WHIT">  </span><span class="COMM">/* Recursively render all instances of this mark. */</span><span class="WHIT">
<span class='line'>798</span> </span><span class="WHIT">  </span><span class="NAME">this.context</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>799</span> </span><span class="WHIT">      </span><span class="NAME">parent</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">parent.scene</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>800</span> </span><span class="WHIT">      </span><span class="NAME">parent</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">parent.index</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>801</span> </span><span class="WHIT">      </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">render</span><span class="PUNC">(</span><span class="NAME">this.root</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>802</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>803</span> 
<span class='line'>804</span> </span><span class="COMM">/** @private Stores the current data stack. */</span><span class="WHIT">
<span class='line'>805</span> </span><span class="NAME">pv.Mark.stack</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>806</span> 
<span class='line'>807</span> </span><span class="COMM">/**
<span class='line'>808</span>  * @private In the bind phase, inherited property definitions are cached so they
<span class='line'>809</span>  * do not need to be queried during build.
<span class='line'>810</span>  */</span><span class="WHIT">
<span class='line'>811</span> </span><span class="NAME">pv.Mark.prototype.bind</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>812</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">seen</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">types</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">visible</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>813</span> 
<span class='line'>814</span> </span><span class="WHIT">  </span><span class="COMM">/** Scans the proto chain for the specified mark. */</span><span class="WHIT">
<span class='line'>815</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">bind</span><span class="PUNC">(</span><span class="NAME">mark</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>816</span> </span><span class="WHIT">    </span><span class="KEYW">do</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>817</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">properties</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mark.$properties</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>818</span> </span><span class="WHIT">      </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">properties.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">--</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>819</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">properties</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>820</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">p.name</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">seen</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>821</span> </span><span class="WHIT">          </span><span class="NAME">seen</span><span class="PUNC">[</span><span class="NAME">p.name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>822</span> </span><span class="WHIT">          </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p.name</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>823</span> </span><span class="WHIT">            </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"data"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>824</span> </span><span class="WHIT">            </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"visible"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">visible</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>825</span> </span><span class="WHIT">            </span><span class="KEYW">default</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">types</span><span class="PUNC">[</span><span class="NAME">p.type</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>826</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>827</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>828</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>829</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">mark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mark.proto</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>830</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>831</span> 
<span class='line'>832</span> </span><span class="WHIT">  </span><span class="COMM">/* Scan the proto chain for all defined properties. */</span><span class="WHIT">
<span class='line'>833</span> </span><span class="WHIT">  </span><span class="NAME">bind</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>834</span> </span><span class="WHIT">  </span><span class="NAME">bind</span><span class="PUNC">(</span><span class="NAME">this.defaults</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>835</span> </span><span class="WHIT">  </span><span class="NAME">types</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">reverse</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>836</span> </span><span class="WHIT">  </span><span class="NAME">types</span><span class="PUNC">[</span><span class="NUMB">3</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">reverse</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>837</span> 
<span class='line'>838</span> </span><span class="WHIT">  </span><span class="COMM">/* Any undefined properties are null. */</span><span class="WHIT">
<span class='line'>839</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">mark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>840</span> </span><span class="WHIT">  </span><span class="KEYW">do</span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">name</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">mark.properties</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>841</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">name</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">seen</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>842</span> </span><span class="WHIT">      </span><span class="NAME">types</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">seen</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">name</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>843</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>844</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">mark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mark.proto</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>845</span> 
<span class='line'>846</span> </span><span class="WHIT">  </span><span class="COMM">/* Define setter-getter for inherited defs. */</span><span class="WHIT">
<span class='line'>847</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">defs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">types</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">concat</span><span class="PUNC">(</span><span class="NAME">types</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>848</span> </span><span class="WHIT">  </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">defs.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>849</span> </span><span class="WHIT">    </span><span class="NAME">this.propertyMethod</span><span class="PUNC">(</span><span class="NAME">defs</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>850</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>851</span> 
<span class='line'>852</span> </span><span class="WHIT">  </span><span class="COMM">/* Setup binds to evaluate constants before functions. */</span><span class="WHIT">
<span class='line'>853</span> </span><span class="WHIT">  </span><span class="NAME">this.binds</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>854</span> </span><span class="WHIT">    </span><span class="NAME">properties</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">seen</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>855</span> </span><span class="WHIT">    </span><span class="NAME">data</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>856</span> </span><span class="WHIT">    </span><span class="NAME">defs</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">defs</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>857</span> </span><span class="WHIT">    </span><span class="NAME">required</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">visible</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>858</span> </span><span class="WHIT">    </span><span class="NAME">optional</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pv.blend</span><span class="PUNC">(</span><span class="NAME">types</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>859</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>860</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>861</span> 
<span class='line'>862</span> </span><span class="COMM">/**
<span class='line'>863</span>  * @private Evaluates properties and computes implied properties. Properties are
<span class='line'>864</span>  * stored in the {@link #scene} array for each instance of this mark.
<span class='line'>865</span>  *
<span class='line'>866</span>  * &lt;p>As marks are built recursively, the {@link #index} property is updated to
<span class='line'>867</span>  * match the current index into the data array for each mark. Note that the
<span class='line'>868</span>  * index property is only set for the mark currently being built and its
<span class='line'>869</span>  * enclosing parent panels. The index property for other marks is unset, but is
<span class='line'>870</span>  * inherited from the global &lt;tt>Mark&lt;/tt> class prototype. This allows mark
<span class='line'>871</span>  * properties to refer to properties on other marks &lt;i>in the same panel&lt;/i>
<span class='line'>872</span>  * conveniently; however, in general it is better to reference mark instances
<span class='line'>873</span>  * specifically through the scene graph rather than depending on the magical
<span class='line'>874</span>  * behavior of {@link #index}.
<span class='line'>875</span>  *
<span class='line'>876</span>  * &lt;p>The root scene array has a special property, &lt;tt>data&lt;/tt>, which stores
<span class='line'>877</span>  * the current data stack. The first element in this stack is the current datum,
<span class='line'>878</span>  * followed by the datum of the enclosing parent panel, and so on. The data
<span class='line'>879</span>  * stack should not be accessed directly; instead, property functions are passed
<span class='line'>880</span>  * the current data stack as arguments.
<span class='line'>881</span>  *
<span class='line'>882</span>  * &lt;p>The evaluation of the &lt;tt>data&lt;/tt> and &lt;tt>visible&lt;/tt> properties is
<span class='line'>883</span>  * special. The &lt;tt>data&lt;/tt> property is evaluated first; unlike the other
<span class='line'>884</span>  * properties, the data stack is from the parent panel, rather than the current
<span class='line'>885</span>  * mark, since the data is not defined until the data property is evaluated.
<span class='line'>886</span>  * The &lt;tt>visisble&lt;/tt> property is subsequently evaluated for each instance;
<span class='line'>887</span>  * only if true will the {@link #buildInstance} method be called, evaluating
<span class='line'>888</span>  * other properties and recursively building the scene graph.
<span class='line'>889</span>  *
<span class='line'>890</span>  * &lt;p>If this mark is being re-built, any old instances of this mark that no
<span class='line'>891</span>  * longer exist (because the new data array contains fewer elements) will be
<span class='line'>892</span>  * cleared using {@link #clearInstance}.
<span class='line'>893</span>  *
<span class='line'>894</span>  * @param parent the instance of the parent panel from the scene graph.
<span class='line'>895</span>  */</span><span class="WHIT">
<span class='line'>896</span> </span><span class="NAME">pv.Mark.prototype.build</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>897</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">scene</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.scene</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">stack</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.Mark.stack</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>898</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">scene</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>899</span> </span><span class="WHIT">    </span><span class="NAME">scene</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.scene</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>900</span> </span><span class="WHIT">    </span><span class="NAME">scene.mark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>901</span> </span><span class="WHIT">    </span><span class="NAME">scene.type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.type</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>902</span> </span><span class="WHIT">    </span><span class="NAME">scene.childIndex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.childIndex</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>903</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.parent</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>904</span> </span><span class="WHIT">      </span><span class="NAME">scene.parent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.parent.scene</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>905</span> </span><span class="WHIT">      </span><span class="NAME">scene.parentIndex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.parent.index</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>906</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>907</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>908</span> 
<span class='line'>909</span> </span><span class="WHIT">  </span><span class="COMM">/* Evaluate defs. */</span><span class="WHIT">
<span class='line'>910</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.binds.defs.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>911</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">defs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scene.defs</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>912</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">defs</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">scene.defs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">defs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>913</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">this.binds.defs.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>914</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.binds.defs</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">defs</span><span class="PUNC">[</span><span class="NAME">p.name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>915</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p.id</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">d.id</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>916</span> </span><span class="WHIT">        </span><span class="NAME">defs</span><span class="PUNC">[</span><span class="NAME">p.name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>917</span> </span><span class="WHIT">          </span><span class="NAME">id</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// this def will be re-evaluated on next build</span><span class="WHIT">
<span class='line'>918</span> </span><span class="WHIT">          </span><span class="NAME">value</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p.type</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">p.value.apply</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">stack</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">p.value</span><span class="WHIT">
<span class='line'>919</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>920</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>921</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>922</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>923</span> 
<span class='line'>924</span> </span><span class="WHIT">  </span><span class="COMM">/* Evaluate special data property. */</span><span class="WHIT">
<span class='line'>925</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.binds.data</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>926</span> </span><span class="WHIT">  </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data.type</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">data.value.apply</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">stack</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">data.value</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>927</span> 
<span class='line'>928</span> </span><span class="WHIT">  </span><span class="COMM">/* Create, update and delete scene nodes. */</span><span class="WHIT">
<span class='line'>929</span> </span><span class="WHIT">  </span><span class="NAME">stack.unshift</span><span class="PUNC">(</span><span class="KEYW">null</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>930</span> </span><span class="WHIT">  </span><span class="NAME">scene.length</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>931</span> </span><span class="WHIT">  </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">data.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>932</span> </span><span class="WHIT">    </span><span class="NAME">pv.Mark.prototype.index</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.index</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>933</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scene</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>934</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">scene</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>935</span> </span><span class="WHIT">    </span><span class="NAME">s.data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">stack</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>936</span> </span><span class="WHIT">    </span><span class="NAME">this.buildInstance</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>937</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>938</span> </span><span class="WHIT">  </span><span class="NAME">pv.Mark.prototype.index</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>939</span> </span><span class="WHIT">  </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">this.index</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>940</span> </span><span class="WHIT">  </span><span class="NAME">stack.shift</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>941</span> 
<span class='line'>942</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>943</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>944</span> 
<span class='line'>945</span> </span><span class="COMM">/**
<span class='line'>946</span>  * @private Evaluates the specified array of properties for the specified
<span class='line'>947</span>  * instance &lt;tt>s&lt;/tt> in the scene graph.
<span class='line'>948</span>  *
<span class='line'>949</span>  * @param s a node in the scene graph; the instance of the mark to build.
<span class='line'>950</span>  * @param properties an array of properties.
<span class='line'>951</span>  */</span><span class="WHIT">
<span class='line'>952</span> </span><span class="NAME">pv.Mark.prototype.buildProperties</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">properties</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>953</span> </span><span class="WHIT">  </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">properties.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>954</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">properties</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">p.value</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// assume case 2 (constant)</span><span class="WHIT">
<span class='line'>955</span> </span><span class="WHIT">    </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p.type</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>956</span> </span><span class="WHIT">      </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>957</span> </span><span class="WHIT">      </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.scene.defs</span><span class="PUNC">[</span><span class="NAME">p.name</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>958</span> </span><span class="WHIT">      </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">v.apply</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pv.Mark.stack</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>959</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>960</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="PUNC">[</span><span class="NAME">p.name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>961</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>962</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>963</span> 
<span class='line'>964</span> </span><span class="COMM">/**
<span class='line'>965</span>  * @private Evaluates all of the properties for this mark for the specified
<span class='line'>966</span>  * instance &lt;tt>s&lt;/tt> in the scene graph. The set of properties to evaluate is
<span class='line'>967</span>  * retrieved from the {@link #properties} array for this mark type (see {@link
<span class='line'>968</span>  * #type}).  After these properties are evaluated, any &lt;b>implied&lt;/b> properties
<span class='line'>969</span>  * may be computed by the mark and set on the scene graph; see
<span class='line'>970</span>  * {@link #buildImplied}.
<span class='line'>971</span>  *
<span class='line'>972</span>  * &lt;p>For panels, this method recursively builds the scene graph for all child
<span class='line'>973</span>  * marks as well. In general, this method should not need to be overridden by
<span class='line'>974</span>  * concrete mark types.
<span class='line'>975</span>  *
<span class='line'>976</span>  * @param s a node in the scene graph; the instance of the mark to build.
<span class='line'>977</span>  */</span><span class="WHIT">
<span class='line'>978</span> </span><span class="NAME">pv.Mark.prototype.buildInstance</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>979</span> </span><span class="WHIT">  </span><span class="NAME">this.buildProperties</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.binds.required</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>980</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.visible</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>981</span> </span><span class="WHIT">    </span><span class="NAME">this.buildProperties</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.binds.optional</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>982</span> </span><span class="WHIT">    </span><span class="NAME">this.buildImplied</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>983</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>984</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>985</span> 
<span class='line'>986</span> </span><span class="COMM">/**
<span class='line'>987</span>  * @private Computes the implied properties for this mark for the specified
<span class='line'>988</span>  * instance &lt;tt>s&lt;/tt> in the scene graph. Implied properties are those with
<span class='line'>989</span>  * dependencies on multiple other properties; for example, the width property
<span class='line'>990</span>  * may be implied if the left and right properties are set. This method can be
<span class='line'>991</span>  * overridden by concrete mark types to define new implied properties, if
<span class='line'>992</span>  * necessary.
<span class='line'>993</span>  *
<span class='line'>994</span>  * @param s a node in the scene graph; the instance of the mark to build.
<span class='line'>995</span>  */</span><span class="WHIT">
<span class='line'>996</span> </span><span class="NAME">pv.Mark.prototype.buildImplied</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>997</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.left</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>998</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.right</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>999</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.top</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1000</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">b</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.bottom</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1001</span> 
<span class='line'>1002</span> </span><span class="WHIT">  </span><span class="COMM">/* Assume width and height are zero if not supported by this mark type. */</span><span class="WHIT">
<span class='line'>1003</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.properties</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1004</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">p.width</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">s.width</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1005</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">p.height</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">s.height</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1006</span> 
<span class='line'>1007</span> </span><span class="WHIT">  </span><span class="COMM">/* Compute implied width, right and left. */</span><span class="WHIT">
<span class='line'>1008</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">width</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.parent</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">this.parent.width</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1009</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1010</span> </span><span class="WHIT">    </span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">width</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1011</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1012</span> </span><span class="WHIT">    </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">width</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1013</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1014</span> </span><span class="WHIT">    </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">width</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1015</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1016</span> 
<span class='line'>1017</span> </span><span class="WHIT">  </span><span class="COMM">/* Compute implied height, bottom and top. */</span><span class="WHIT">
<span class='line'>1018</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">height</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.parent</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">this.parent.height</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1019</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1020</span> </span><span class="WHIT">    </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">height</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">b</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1021</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">b</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1022</span> </span><span class="WHIT">    </span><span class="NAME">b</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">height</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1023</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1024</span> </span><span class="WHIT">    </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">height</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">b</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1025</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1026</span> 
<span class='line'>1027</span> </span><span class="WHIT">  </span><span class="NAME">s.left</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1028</span> </span><span class="WHIT">  </span><span class="NAME">s.right</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1029</span> </span><span class="WHIT">  </span><span class="NAME">s.top</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1030</span> </span><span class="WHIT">  </span><span class="NAME">s.bottom</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1031</span> 
<span class='line'>1032</span> </span><span class="WHIT">  </span><span class="COMM">/* Only set width and height if they are supported by this mark type. */</span><span class="WHIT">
<span class='line'>1033</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p.width</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">s.width</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">w</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1034</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p.height</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">s.height</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1035</span> 
<span class='line'>1036</span> </span><span class="WHIT">  </span><span class="COMM">/* Set any null colors to pv.Color.transparent. */</span><span class="WHIT">
<span class='line'>1037</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p.textStyle</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">s.textStyle</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">s.textStyle</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.Color.transparent</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1038</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p.fillStyle</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">s.fillStyle</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">s.fillStyle</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.Color.transparent</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1039</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p.strokeStyle</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">s.strokeStyle</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">s.strokeStyle</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.Color.transparent</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1040</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1041</span> 
<span class='line'>1042</span> </span><span class="COMM">/**
<span class='line'>1043</span>  * Returns the current location of the mouse (cursor) relative to this mark's
<span class='line'>1044</span>  * parent. The &lt;i>x&lt;/i> coordinate corresponds to the left margin, while the
<span class='line'>1045</span>  * &lt;i>y&lt;/i> coordinate corresponds to the top margin.
<span class='line'>1046</span>  *
<span class='line'>1047</span>  * @returns {pv.Vector} the mouse location.
<span class='line'>1048</span>  */</span><span class="WHIT">
<span class='line'>1049</span> </span><span class="NAME">pv.Mark.prototype.mouse</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1050</span> 
<span class='line'>1051</span> </span><span class="WHIT">  </span><span class="COMM">/* Compute xy-coordinates relative to the panel. */</span><span class="WHIT">
<span class='line'>1052</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.event.pageX</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1053</span> </span><span class="WHIT">      </span><span class="NAME">y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.event.pageY</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1054</span> </span><span class="WHIT">      </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.root.canvas</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1055</span> </span><span class="WHIT">  </span><span class="KEYW">do</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1056</span> </span><span class="WHIT">    </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.offsetLeft</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1057</span> </span><span class="WHIT">    </span><span class="NAME">y</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.offsetTop</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1058</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.offsetParent</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1059</span> 
<span class='line'>1060</span> </span><span class="WHIT">  </span><span class="COMM">/* Compute the inverse transform of all enclosing panels. */</span><span class="WHIT">
<span class='line'>1061</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.Transform.identity</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1062</span> </span><span class="WHIT">      </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.properties.transform</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">this.parent</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1063</span> </span><span class="WHIT">      </span><span class="NAME">pz</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1064</span> </span><span class="WHIT">  </span><span class="KEYW">do</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">pz.push</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">p.parent</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1065</span> </span><span class="WHIT">  </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pz.pop</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">t.translate</span><span class="PUNC">(</span><span class="NAME">p.left</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.top</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">times</span><span class="PUNC">(</span><span class="NAME">p.transform</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1066</span> </span><span class="WHIT">  </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">t.invert</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1067</span> 
<span class='line'>1068</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pv.vector</span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">t.k</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">t.x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">t.k</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">t.y</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1069</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1070</span> 
<span class='line'>1071</span> </span><span class="COMM">/**
<span class='line'>1072</span>  * Registers an event handler for the specified event type with this mark. When
<span class='line'>1073</span>  * an event of the specified type is triggered, the specified handler will be
<span class='line'>1074</span>  * invoked. The handler is invoked in a similar method to property functions:
<span class='line'>1075</span>  * the context is &lt;tt>this&lt;/tt> mark instance, and the arguments are the full
<span class='line'>1076</span>  * data stack. Event handlers can use property methods to manipulate the display
<span class='line'>1077</span>  * properties of the mark:
<span class='line'>1078</span>  *
<span class='line'>1079</span>  * &lt;pre>m.event("click", function() this.fillStyle("red"));&lt;/pre>
<span class='line'>1080</span>  *
<span class='line'>1081</span>  * Alternatively, the external data can be manipulated and the visualization
<span class='line'>1082</span>  * redrawn:
<span class='line'>1083</span>  *
<span class='line'>1084</span>  * &lt;pre>m.event("click", function(d) {
<span class='line'>1085</span>  *     data = all.filter(function(k) k.name == d);
<span class='line'>1086</span>  *     vis.render();
<span class='line'>1087</span>  *   });&lt;/pre>
<span class='line'>1088</span>  *
<span class='line'>1089</span>  * The return value of the event handler determines which mark gets re-rendered.
<span class='line'>1090</span>  * Use defs ({@link #def}) to set temporary state from event handlers.
<span class='line'>1091</span>  *
<span class='line'>1092</span>  * &lt;p>The complete set of event types is defined by SVG; see the reference
<span class='line'>1093</span>  * below. The set of supported event types is:&lt;ul>
<span class='line'>1094</span>  *
<span class='line'>1095</span>  * &lt;li>click
<span class='line'>1096</span>  * &lt;li>mousedown
<span class='line'>1097</span>  * &lt;li>mouseup
<span class='line'>1098</span>  * &lt;li>mouseover
<span class='line'>1099</span>  * &lt;li>mousemove
<span class='line'>1100</span>  * &lt;li>mouseout
<span class='line'>1101</span>  *
<span class='line'>1102</span>  * &lt;/ul>Since Protovis does not specify any concept of focus, it does not
<span class='line'>1103</span>  * support key events; these should be handled outside the visualization using
<span class='line'>1104</span>  * standard JavaScript. In the future, support for interaction may be extended
<span class='line'>1105</span>  * to support additional event types, particularly those most relevant to
<span class='line'>1106</span>  * interactive visualization, such as selection.
<span class='line'>1107</span>  *
<span class='line'>1108</span>  * &lt;p>TODO In the current implementation, event handlers are not inherited from
<span class='line'>1109</span>  * prototype marks. They must be defined explicitly on each interactive mark. In
<span class='line'>1110</span>  * addition, only one event handler for a given event type can be defined; when
<span class='line'>1111</span>  * specifying multiple event handlers for the same type, only the last one will
<span class='line'>1112</span>  * be used.
<span class='line'>1113</span>  *
<span class='line'>1114</span>  * @see &lt;a href="http://www.w3.org/TR/SVGTiny12/interact.html#SVGEvents">SVG events&lt;/a>
<span class='line'>1115</span>  * @param {string} type the event type.
<span class='line'>1116</span>  * @param {function} handler the event handler.
<span class='line'>1117</span>  * @returns {pv.Mark} this.
<span class='line'>1118</span>  */</span><span class="WHIT">
<span class='line'>1119</span> </span><span class="NAME">pv.Mark.prototype.event</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">handler</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1120</span> </span><span class="WHIT">  </span><span class="NAME">this.$handlers</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.functor</span><span class="PUNC">(</span><span class="NAME">handler</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1121</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1122</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1123</span> 
<span class='line'>1124</span> </span><span class="COMM">/** @private Evaluates the function &lt;i>f&lt;/i> with the specified context. */</span><span class="WHIT">
<span class='line'>1125</span> </span><span class="NAME">pv.Mark.prototype.context</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">scene</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">index</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1126</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">proto</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.Mark.prototype</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1127</span> </span><span class="WHIT">      </span><span class="NAME">stack</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.Mark.stack</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1128</span> </span><span class="WHIT">      </span><span class="NAME">oscene</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.Mark.scene</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1129</span> </span><span class="WHIT">      </span><span class="NAME">oindex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">proto.index</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1130</span> 
<span class='line'>1131</span> </span><span class="WHIT">  </span><span class="COMM">/** @private Sets the context. */</span><span class="WHIT">
<span class='line'>1132</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">apply</span><span class="PUNC">(</span><span class="NAME">scene</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">index</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1133</span> </span><span class="WHIT">    </span><span class="NAME">pv.Mark.scene</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scene</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1134</span> </span><span class="WHIT">    </span><span class="NAME">proto.index</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">index</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1135</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">scene</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1136</span> 
<span class='line'>1137</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">that</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scene.mark</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1138</span> </span><span class="WHIT">        </span><span class="NAME">mark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">that</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1139</span> </span><span class="WHIT">        </span><span class="NAME">ancestors</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1140</span> 
<span class='line'>1141</span> </span><span class="WHIT">    </span><span class="COMM">/* Set ancestors' scene and index; populate data stack. */</span><span class="WHIT">
<span class='line'>1142</span> </span><span class="WHIT">    </span><span class="KEYW">do</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1143</span> </span><span class="WHIT">      </span><span class="NAME">ancestors.push</span><span class="PUNC">(</span><span class="NAME">mark</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1144</span> </span><span class="WHIT">      </span><span class="NAME">stack.push</span><span class="PUNC">(</span><span class="NAME">scene</span><span class="PUNC">[</span><span class="NAME">index</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">data</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1145</span> </span><span class="WHIT">      </span><span class="NAME">mark.index</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">index</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1146</span> </span><span class="WHIT">      </span><span class="NAME">mark.scene</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scene</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1147</span> </span><span class="WHIT">      </span><span class="NAME">index</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scene.parentIndex</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1148</span> </span><span class="WHIT">      </span><span class="NAME">scene</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scene.parent</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1149</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">mark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mark.parent</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1150</span> 
<span class='line'>1151</span> </span><span class="WHIT">    </span><span class="COMM">/* Set ancestors' scale; requires top-down. */</span><span class="WHIT">
<span class='line'>1152</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ancestors.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">--</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1153</span> </span><span class="WHIT">      </span><span class="NAME">mark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ancestors</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1154</span> </span><span class="WHIT">      </span><span class="NAME">mark.scale</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1155</span> </span><span class="WHIT">      </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mark.scene</span><span class="PUNC">[</span><span class="NAME">mark.index</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">transform.k</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1156</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1157</span> 
<span class='line'>1158</span> </span><span class="WHIT">    </span><span class="COMM">/* Set children's scene and scale. */</span><span class="WHIT">
<span class='line'>1159</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">that.children</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">that.children.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1160</span> </span><span class="WHIT">      </span><span class="NAME">mark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">that.children</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1161</span> </span><span class="WHIT">      </span><span class="NAME">mark.scene</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">that.scene</span><span class="PUNC">[</span><span class="NAME">that.index</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">children</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1162</span> </span><span class="WHIT">      </span><span class="NAME">mark.scale</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1163</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1164</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1165</span> 
<span class='line'>1166</span> </span><span class="WHIT">  </span><span class="COMM">/** @private Clears the context. */</span><span class="WHIT">
<span class='line'>1167</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">clear</span><span class="PUNC">(</span><span class="NAME">scene</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">index</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1168</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">scene</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1169</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">that</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scene.mark</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1170</span> </span><span class="WHIT">        </span><span class="NAME">mark</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1171</span> 
<span class='line'>1172</span> </span><span class="WHIT">    </span><span class="COMM">/* Reset children. */</span><span class="WHIT">
<span class='line'>1173</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">that.children</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">that.children.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1174</span> </span><span class="WHIT">      </span><span class="NAME">mark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">that.children</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1175</span> </span><span class="WHIT">      </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">mark.scene</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1176</span> </span><span class="WHIT">      </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">mark.scale</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1177</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1178</span> 
<span class='line'>1179</span> </span><span class="WHIT">    </span><span class="COMM">/* Reset ancestors. */</span><span class="WHIT">
<span class='line'>1180</span> </span><span class="WHIT">    </span><span class="NAME">mark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">that</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1181</span> </span><span class="WHIT">    </span><span class="KEYW">do</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1182</span> </span><span class="WHIT">      </span><span class="NAME">stack.pop</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1183</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">mark.parent</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1184</span> </span><span class="WHIT">        </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">mark.scene</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1185</span> </span><span class="WHIT">        </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">mark.scale</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1186</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1187</span> </span><span class="WHIT">      </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">mark.index</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1188</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">mark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mark.parent</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1189</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1190</span> 
<span class='line'>1191</span> </span><span class="WHIT">  </span><span class="COMM">/* Context switch, invoke the function, then switch back. */</span><span class="WHIT">
<span class='line'>1192</span> </span><span class="WHIT">  </span><span class="NAME">clear</span><span class="PUNC">(</span><span class="NAME">oscene</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">oindex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1193</span> </span><span class="WHIT">  </span><span class="NAME">apply</span><span class="PUNC">(</span><span class="NAME">scene</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">index</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1194</span> </span><span class="WHIT">  </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1195</span> </span><span class="WHIT">    </span><span class="NAME">f.apply</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">stack</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1196</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">finally</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1197</span> </span><span class="WHIT">    </span><span class="NAME">clear</span><span class="PUNC">(</span><span class="NAME">scene</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">index</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1198</span> </span><span class="WHIT">    </span><span class="NAME">apply</span><span class="PUNC">(</span><span class="NAME">oscene</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">oindex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1199</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1200</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1201</span> 
<span class='line'>1202</span> </span><span class="COMM">/** @private Execute the event listener, then re-render. */</span><span class="WHIT">
<span class='line'>1203</span> </span><span class="NAME">pv.Mark.dispatch</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">scene</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">index</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1204</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">m</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scene.mark</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scene.parent</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">m.$handlers</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1205</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">l</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">pv.Mark.dispatch</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">scene.parentIndex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1206</span> </span><span class="WHIT">  </span><span class="NAME">m.context</span><span class="PUNC">(</span><span class="NAME">scene</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">index</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1207</span> </span><span class="WHIT">      </span><span class="NAME">m</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">l.apply</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pv.Mark.stack</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1208</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">m</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">m.render</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">m.render</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1209</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1210</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1211</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1212</span> </span></pre></body></html>